
//-----------------------------我要买货  start  ------
//点击输入框下拉类似助记码功能
function showdiv_dj(obj,type,e){
	getList_dj(obj,type);
}
function showdiv(obj,type){
	getList(obj,type);
}

//根据输入的助记码获取list
function getList(obj,type){
	if(type == 1){//获取品名/steNameAction_listSteName.action?
		var url = app.root + '/ste/steAction_listProName_jz.action';
		var data = {"pm":$(obj).val()};
		url = encodeURI(encodeURI(url)); 
		$.post(
			url,
			data,
			function(data){
			var html = '';
			$.each(data,function(idx,item){
				//var h = '<li value="'+item.id+'" onClick="searchlist(this,'+type+','+item.steSortID+',&quot;'+item.steSort+'&quot;)">'+item.steName+'</li>';
				var h = '<li value="'+item.id+'" onClick="searchlist(this,'+type+','+item.steSortID+',&quot;'+item.steSort+'&quot;)">'+item.steName+'</li>';
				html += h;
			});
			$(obj).next("ul").html(html);
		});
	}if(type == 2){//获取材质
		var url = app.root + '/ste/listSteQuality?steQuality.qualityName='+$(obj).val();
		url=url.replace("+", "%2B").replace("+", "%2B").replace("+", "%2B");
		url = encodeURI(encodeURI(url)); 
		$.post(
			url,
			function(data){
			var html = '';
			$.each(data,function(idx,item){
				var h = '<li value="'+item.id+'" onClick="searchlist(this,'+type+')">'+item.qualityName+'</li>';
				html += h;
			});
			$(obj).next("ul").html(html);
		});
	}if(type == 3){//获取钢厂
		var url = app.root + '/ste/listSteArea?steArea.memoCode='+$(obj).val();
		url = encodeURI(encodeURI(url)); 
		$.post(
			url,
			function(data){
			var html = '';
			html += "<li id='0' onclick='changeSteArea(this,event)'  style='cursor:pointer;'>不限</li>";
			$.each(data,function(idx,item){
				html += '<li value="'+item.id+'" onClick="searchlist(this,'+type+')">'+item.areaName+'</li>';
			});
			$(obj).next("ul").html(html);
		});
	}if(type == 4){//获取规格
		var url = app.root + '/ste/listSteSpecForIndex';
		var data = {"gg":$(obj).val()}
		$.post(
			url,
			data,
			function(data){
			var html = '';
			$.each(data,function(idx,item){
				html += '<li value="'+item.id+'" onClick="searchlist(this,'+type+',0,0,event)">'+item.specName+'</li>';
			});
			$(obj).next("ul").html(html);
		});
	}
}
//点击事件根据输入的助记码获取list
function getList_dj(obj,type){
	
	if(type == 1){//获取品名
		var url = app.root + '/ste/listProName_jz';
		var data = {"pm":$(obj).val()};
		url = encodeURI(encodeURI(url)); 
		$.post(
			url,
			data,
			function(data){
			var html = '';
			$.each(data,function(idx,item){
				var h = '<a class="sContentList ell poi" value="'+item.id+'" onClick="searchlist(this,'+type+','+item.steSortID+',&quot;'+item.steSort+'&quot;,event)">'+item.steName+'</a>';
				html += h;
			});
			$(obj).next("div").html(html);
		});
	}if(type == 2){//获取材质
	
		var url = app.root + '/ste/listProQualityNew1';
		$.post(
			url,
			function(data){
			var html = '';
			$.each(data,function(idx,item){
				var h = '<a class="sContentList ell poi" value="'+item.id+'" onClick="searchlist(this,'+type+',0,0,event)">'+item.qualityName+'</a>';
				html += h;
			});
			$(obj).next("div").html(html);
		});
	}if(type == 3){//获取钢厂
		var url = app.root + '/ste/listSteAera?steArea.memoCode='+$(obj).val();
		url = encodeURI(encodeURI(url)); 
		$.post(
			url,
			function(data){
			var html = '<a class="sContentList ell poi" value="0" onClick="searchlist(this,'+type+',0,0,event)"  style="cursor:pointer;">不限</a>';
			$.each(data,function(idx,item){
				html += '<a class="sContentList ell poi" value="'+item.id+'" onClick="searchlist(this,'+type+',0,0,event)">'+item.steArea+'</a>';
			});
			$(obj).next("div").html(html);
		});
	}if(type == 4){//获取规格
		var url = app.root + '/ste/listSteSpecForIndex';
		var data = {"gg":$(obj).val()}
		$.post(
			url,
			data,
			function(data){
			var html = '';
			$.each(data,function(idx,item){
				html += '<a class="sContentList ell poi" value="'+item.id+'" onClick="searchlist(this,'+type+',0,0,event)">'+item.specName+'</a>';
			});
			$(obj).next("div").html(html);
		});
	}
	
	//$(obj).next("div").show();
}



//选择的值传进input（类似助记码功）
function searchlist(obj,type,steSortID,steSort,e){

		if(type==1){
			$(obj).parents(".sContent").prev(".sInput").val($(obj).text());
			$(obj).parents(".sContent").hide();
			$("#purSteSpec").focus();
			$("#purSteSpec").click();
			e.stopPropagation();
		}
		if(type==2){
			$(obj).parents(".sContent").prev(".sInput").val($(obj).text());
			$(obj).parents(".sContent").hide();			$("#purSteArea").focus();
			$("#purSteArea").click();
			e.stopPropagation();
		}
		if(type==3){
			$(obj).parents(".sContent").prev(".sInput").val($(obj).text());
			$(obj).parents(".sContent").hide();
			e.stopPropagation();
		}
		if(type==4){
			$(obj).parents(".sContent").prev(".sInput").val($(obj).text());
			$(obj).parents(".sContent").hide();
			$("#purSteQuality").focus();
			$("#purSteQuality").click();
			e.stopPropagation();
		}
	
}

function wantToBuy(){
	$("#wantToBuyForm [name='pm']").val($("#purSteName").val());
	$("#wantToBuyForm [name='gg']").val($("#purSteSpec").val());
	$("#wantToBuyForm [name='gc']").val($("#purSteArea").val());
	$("#wantToBuyForm [name='cz']").val($("#purSteQuality").val());
	$("#wantToBuyForm").submit();
}

//-----------------------------我要买货  end  ------

//-----------------------------我要卖货  start  ------
function wantToSale(){
	location.href=app.root+"/myLG/supplier/supplierAgreement.html";
}
//-----------------------------我要卖货  end  ------
//-----------------------------我要加工 start  ------


function wtmSetVal(obj,type){
	if(type==1){
		var zoneID=$(obj).attr("val");
		$("#wantToMachineForm #zoneUl").val(zoneID);
		$("#wantToMachineForm #qy").val($(obj).text());
		$(obj).parents(".lg19_searchList").find("#qy2").val($(obj).text());
	}else if(type==2){
		$("#wantToMachineForm #jgfs").val($(obj).text());
		$(obj).parents(".lg19_searchList").find("#jgfs2").val($(obj).text());
	}else if(type==3){
		$("#wantToMachineForm #bzfs").val($(obj).text());
		$(obj).parents(".lg19_searchList").find("#bzfs2").val($(obj).text());
	}else if(type==4){
		
	}
}



function jumpurl(compid,comp,urlMark) {
	   
	$("#compid").val(compid);
	$("#pm2").val($("#stename").val());
	$("#comp").val(comp);
	
   $("#wantToMachineForm").submit();
               
  
   }
//-----------------------------我要加工  end  ------
//-----------------------------我要找车  start  ------


function getListTrans(obj,type){
	if(type==1){//始发地
		var keyword = $.trim($("#startPlaceName").val());
		keyword=keyword.replace(/'/g,"");
		//ajax请求查询出搜索推荐关键词
		$.ajax({
		   type: "POST",
		   url: '/notLoginCartcorp/cartcorpregAction_queryDepotListByKey.action',	 
		   data:{"searchWord":keyword,"orderByType":"desc"},
		   dataType: "json",
		   success: function(data){
			   var keywordTemp = $.trim($("#startPlaceName").val());
			   keywordTemp=keywordTemp.replace(/'/g,"");
			   if(data.searchKey==keywordTemp){
				    var list = data.list;
				    var str = "";
		 			for(var i=0; i<list.length; i++){
		      	      str += "<a class='sContentList ell' sid='"+list[i].id+"' onClick='setValueTrans(this,1)'>"+list[i].depotName+"</a>"
		            } 
		 			$("#startPlaceName").next("div").html(str);

			   }
			   
		   } 
		});
	}else if(type == 2){
		var keyword = $.trim($("#endPlaceName ").val());
		keyword=keyword.replace(/'/g,"");
		//ajax请求查询出搜索推荐关键词
		$.ajax({
		   type: "POST",
		   url: '${context }/notLoginCartcorp/cartcorpregAction_queryDepotListByKey.action',	 
		   data:{"searchWord":keyword,"orderByType":"asc"},
		   dataType: "json",
		   success: function(data){
			   var keywordTemp = $.trim($("#endPlaceName ").val());
			   keywordTemp=keywordTemp.replace(/'/g,"");
			   if(data.searchKey==keywordTemp){
				    var list = data.list;
				    var str = "";
		 			for(var i=0; i<list.length; i++){
		      	      str +="<a class='sContentList ell' onClick='setValueTrans(this,2)'>"+list[i].depotName+"</a>"
		            } 
				$("#endPlaceName").next("div").html(str);
		 			
			   }
			   
		   } 
		});
	}
}

function setValueTrans(obj,type){
	if(type ==1 ){
		$("#startPlaceName").val($(obj).text());
		$("#startPlaceNameID").val($(obj).attr("sid"));
	}else if(type ==2 ){
		$("#endPlaceName").val($(obj).text());
	}else if(type==3){
		$("#transTypeName").val($(obj).text());
	}
}

function wantToTrans(){
        	var startPlaceName = $("#startPlaceName").val();
            var endPlaceName = $("#endPlaceName").val();
            var weight = $("#corpquoteweight").val();
            var transTypeName=$("#transTypeName").val();
            var startPlaceNameID=$("#startPlaceNameID").val();
            if(startPlaceName=="始发仓"){
                startPlaceName="";
            }
            if(endPlaceName=='目的地'){
                endPlaceName="";
            }
            if(weight=='运输重量'){
                weight="";
            }
            $("#wantToTransForm #ttstartPlaceName").val(startPlaceName);
            $("#wantToTransForm #ttendPlaceName").val(endPlaceName);
            $("#wantToTransForm #ttweight").val(weight);
            $("#wantToTransForm #tttransTypeName").val(transTypeName);
            $("#wantToTransForm #ttstartPlaceNameID").val(startPlaceNameID);
            $("#wantToTransForm").submit();
		
	} 

//搜索定位
function getPosition(obj,str){
	if(str==undefined){
		$(obj).next(".sContent").css({"width":$(obj).outerWidth()});		
	}else{
		$(obj).next(".sContent").css({"width":str});
	}
	$(obj).next(".sContent").css({"left":$(obj).offset().left,"top":$(obj).offset().top+$(obj).outerHeight()+1});			
}
//阻止冒泡
function stopPro(e){
	if(navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion.match(/7./i)=="7."|| navigator.appVersion.match(/8./i)=="8.")) 
	{ 
		
		if (event.stopPropagation) { 
		// this code is for Mozilla and Opera 
		event.stopPropagation(); 
		} 
		else if (window.event) { 
		// this code is for IE 
		window.event.cancelBubble = true; 
		}
	}else{
		e.stopPropagation();
 }
}

function show_div(obj,e){
	stopPro(e);
	var obj=obj;
	getPosition(obj);
	$(obj).next(".sContent").show();

}


//-----------------------------我要找车  end  ------

